package it.pride.primefacesShowcase.controller;

import it.pride.primefacesShowcase.model.User;
import it.pride.primefacesShowcase.service.UserService;
import java.util.ArrayList;
import java.util.List;

import org.primefaces.model.DualListModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * Created by IntelliJ IDEA.
 * User: lbonacina
 * Date: 4-nov-2010
 * Time: 17.26.58
 */
@Controller
@Scope("session")
public class MainController {

    @Autowired
    private UserService userService ;
    
    private String selectValue ;

    private String inputString ;
    
    //private List<User> users ;

    private DualListModel<String> cities;

    private List<Check> checkList ;
    
    public String getTitle() {
    	
    	return "Title Here" ;
    }

    public void init() {

        //Cities
        //List<String> citiesSource = userService.findAllCities();
        //List<String> citiesTarget = new ArrayList<String>();
        //cities = new DualListModel<String>(citiesSource, citiesTarget);
        //users = userService.findAll() ;
        checkList = new ArrayList<Check>() ;
        checkList.add(new Check("Check A.1.1"));
        checkList.add(new Check("Check A.1.2"));
        checkList.add(new Check("Check A.1.3"));
    }


    public void addInfoMessage() {

        FacesContext.getCurrentInstance().addMessage("", new FacesMessage(FacesMessage.SEVERITY_INFO,"Info","This is a info message."));
    }

    public void addErrorMessage() {

        FacesContext.getCurrentInstance().addMessage("", new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error","This is a error message."));
    }

    public void submitCheckPanel() {
        
        for ( Check c : checkList) {
            
            System.out.println(c.toString());
        }
    }

    public String getSelectValue() {
        return selectValue;
    }

    public void setSelectValue(String selectValue) {
        this.selectValue = selectValue;
    }

    public DualListModel<String> getCities() {
        return cities;
    }

    public void setCities(DualListModel<String> cities) {
        this.cities = cities;
    }

    public String getInputString() {
        return inputString;
    }

    public void setInputString(String inputString) {
        this.inputString = inputString;
    }

    public List<Check> getCheckList() {
        return checkList;
    }

    public void setCheckList(List<Check> checkList) {
        this.checkList = checkList;
    }
    
    
}
